package com.bilibili.controller;


import com.bilibili.entity.PicRead;
import com.bilibili.service.PicReadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 具体阅读的controller
 * @Author Sandy
 */
@RestController
@RequestMapping("pic_read")
public class PicReadController {

    @Autowired
    private PicReadService picReadService;

    /**
     *
     * @param pageId 漫画id
     * @return 通过漫画id拿到的具体图片的实体类
     */
//    @RequestMapping(value = "getPic", method = RequestMethod.GET, params = {"pageId"})
    @RequestMapping(method = RequestMethod.GET, params = {"pageId"})
    public List<PicRead> getPicReadByPageId(@RequestParam("pageId") Integer pageId) {
        return picReadService.getPicReadByPageId(pageId);
    }

    /**
     *
     * @param number 表示这是第几章节
     * @param cartoonId 漫画id
     * @param action 想查第几页
     * @return 所请求章节每一张图片的实体类的集合(已经完成排序)
     */
//    @RequestMapping(value = "getPagesByNumberAndCartoonId", method = RequestMethod.GET, params = {"number","cartoonId","action"})
    @RequestMapping(method = RequestMethod.GET, params = {"number","cartoonId","action"})
    public List<PicRead> getPagesByNumberAndCartoonId(@RequestParam("number") Integer number,@RequestParam("cartoonId") Integer cartoonId,@RequestParam("action") Integer action) {
        return picReadService.getPagesByNumberAndCartoonId(number, cartoonId, action);
    }

}
